/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package ru.vsu.csf.qasystem.morph.data;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import ru.vsu.csf.qasystem.morph.Word;

/**
 * Морфологический словарь.
 * @author Руслан
 */
public class MorphDictionary {
    
    private Map<String,List<Word>> dictionary;

    public MorphDictionary(){
        dictionary = new HashMap<String, List<Word>>();
    }
    
    public void addWordForms(String word, List<Word> wordForms) {
        if (!dictionary.containsKey(word))
            dictionary.put(word, wordForms);
        else dictionary.get(word).addAll(wordForms);
    }
    
    public void addWordForm(Word wordForm) {
        if (dictionary.containsKey(wordForm.getText())) dictionary.get(wordForm.getText()).add(wordForm);
        else {
            List<Word> list = new LinkedList<Word>();
            list.add(wordForm);
            dictionary.put(wordForm.getText(), list);
        }
    }
    
    public Integer getWordCount() {
        return dictionary.size();
    }
    
    public List<Word> getWords(String form) {
        return dictionary.get(form);
    }
}
